package com.wn.production.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wn.common.PageBean;
import com.wn.entity.MeasuringDevice;
import com.wn.production.mapper.MeasuringDeviceMapper;
import com.wn.production.service.MeasuringDeviceService;
import com.wn.production.vo.MeasuringDeviceVo;
import com.wn.utils.CurrentTime;
import com.wn.utils.PageBeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MeasuringDeviceMapperImpl implements MeasuringDeviceService {
    @Autowired
    private MeasuringDeviceMapper measuringDeviceMapper;
    @Override
    public void insert(MeasuringDevice measuringDevice) {
        String number="TNT"+ CurrentTime.getCurrentTimeString();
        measuringDevice.setMeasuringDeviceNumber(number);
        measuringDeviceMapper.insert(measuringDevice);
    }

    @Override
    public PageBean<MeasuringDevice> getByCondition(MeasuringDeviceVo measuringDeviceVo) {
        Page<MeasuringDevice> page = PageHelper.startPage(measuringDeviceVo.getCurrPage(), measuringDeviceVo.getPageSize());
        List<MeasuringDevice> list = measuringDeviceMapper.getByCondition(measuringDeviceVo.getMeasuringDevice());
        return PageBeanUtil.getPageBean(list,page,measuringDeviceVo.getCurrPage(),measuringDeviceVo.getPageSize());
    }

    @Override
    public void update(MeasuringDevice measuringDevice) {
        measuringDeviceMapper.update(measuringDevice);
    }
}
